package android.development;

import android.graphics.*;

public class Droid {

	private Bitmap bitmap; // The actual bitmap of the droid
	private int x; // The X coordinate
	private int y; // The Y coordinate
	private boolean touched; // If droid is touched/picked up
	
	public Droid( Bitmap bitmap, int x, int y )
	{
		this.bitmap = bitmap;
		this.x = x;
		this.y = y;
	}
	
	public Bitmap getBitmap()
	{
		return bitmap;
	}
	
	public void setBitBitmap( Bitmap bitmap )
	{
		this.bitmap = bitmap;
	}
	
	public int getX()
	{
		return x;
	}
	
	public void setX( int x )
	{
		this.x = x;
	}
	
	public int getY()
	{
		return y;
	}
	
	public void setY( int y )
	{
		this.y = y;
	}
	
	public boolean isTouched()
	{
		return touched;
	}
	
	public void setTouched( boolean touched )
	{
		this.touched = touched;
	}
	
	public void draw( Canvas canvas )
	{
		canvas.drawBitmap(bitmap, x - (bitmap.getWidth() / 2) , y - (bitmap.getHeight() / 2), null);
	}
	
	public void handleActionDown( int eventX, int eventY )
	{
		if( eventX >= (x - bitmap.getWidth() / 2) && (eventX <= (x + bitmap.getWidth() / 2)))
		{
			if( eventY >= (y - bitmap.getHeight() / 2) && (y <= (y + bitmap.getHeight() / 2)))
			{
				//Droid is touched
				setTouched(true);
			}
			else
			{
				setTouched(false);
			}
		}
		else 
		{
			setTouched(false);	
		
		}
	}
}
